<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ page import="java.text.SimpleDateFormat"%>
<%@ page import="java.util.Calendar"%>
<%@ page import="edu.sysu.cshare.model.SubmitInfo"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><s:text name="title.homework" /></title>
<script type="text/javascript" src="js/ajax.js">
	
</script>
    <link href="css/960.css" rel="stylesheet" type="text/css" />
    <link href="css/area.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="area.css" />
<style type="text/css">
    .style1
    {
        height: 45px;
        width: 224px;
    }
    .style2
    {
        width: 68px;
    }
    .style3
    {
        height: 45px;
        width: 68px;
    }
    .style4
    {
        width: 297px;
        height: 180px;
    }
    .style5
    {
        width: 224px;
    }
</style>
</head>
<body>
   <div id="container" class="container_12">
   <div id="head" class="grid_12">
     <center><font color="red" size="25px">CShare作业提交系统</font></center>
     <div id="logo" class="grid_3"></div>
     <div id="logoright" class="grid_8">
     </div>
     <div class="clear"></div>
   </div><!--end of head-->
   <div id=content class="grid_12">
	    <jsp:include page="top.jsp" flush="true" />
	<s:form name="viewHomework1" action="homework!viewHomework" method="post">
		<s:hidden name="userId" />
		<s:checkbox name="showUnDone" onclick="viewHomework1.submit()" />
		<s:text name="label.unDone" />
		<s:checkbox name="showDone" onclick="viewHomework1.submit()" />
		<s:text name="label.done" />
	</s:form>
	<table border="1">
		<tr>
			<th><s:text name="label.courseName" /></th>
			<th><s:text name="label.homeworkDescription" /></th>
			<th><s:text name="label.deadline" /></th>
			<th><s:text name="label.seeDetails" /></th>
			<th><s:text name="label.handup" /></th>
		</tr>
		<%
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH点");
		%>
		<s:iterator value="user.submitInfos" id="submitInfo">
			<s:if
				test="(showUnDone==true&&#submitInfo.submitDate==null)||(showDone==true&&#submitInfo.submitDate!=null)">
				<tr>
					<td><s:property value="homework.course.name" />
					</td>
					<td><s:property value="homework.descrip" /></td>
					<td>
						<%
							String dueDateStr = sdf.format(((SubmitInfo) request
											.getAttribute("submitInfo")).getHomework()
											.getDueDate().getTime());
									out.print(dueDateStr);
						%>
					</td>
					<td><s:form action="homework!viewDetails">
							<s:submit key="label.seeDetails" />
							<s:hidden name="homeworkId" value="%{homework.id}" />
							<s:hidden name="userId" />
							<s:hidden name="showUnDone" />
							<s:hidden name="showDone" />
						</s:form></td>
					<td><s:form action="homework!submitHomework" method="post"
							enctype="multipart/form-data">
							<s:file name="submitFile" />
							<s:submit key="label.handup" />
							<s:hidden name="userId" />
							<s:hidden name="showUnDone" />
							<s:hidden name="showDone" />
							<s:hidden name="submitInfoId" value="%{id}" />
						</s:form></td>
				</tr>
			</s:if>
		</s:iterator>
	</table>
	${submitMsg}
   </div><!--content-->	
  </div>
</body>
</html>